package src.Players;

import src.Packets.*;
import src.Main;

public class PlayerWeapon
{
    public Player p;

    public PlayerWeapon(Player _p)
    {
        p = _p;
    }

    public void sendWeapon()
    {
        if(p == null)
        {
            return;
        }
        p.walkEmote = getWalkEmote(p.equipment[3]);
        p.runEmote = getRunEmote(p.equipment[3]);
        p.standEmote = getStandEmote(p.equipment[3]);
        String weapon = Main.m.ge.item.getItemName(p.equipment[3]);
        if(p.equipment[3] == -1)
        {
            p.frame.setSidebar(p, 5855, 0);
            p.frame.setText126(p, weapon, 5857);
        }
        else if(weapon.equals("Abyssal whip"))
        {
            p.frame.setSidebar(p, 12290, 0);
            p.frame.setInterfaceItem(p, 12291, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 12293);
        }
        else if(weapon.equals("Granite maul") || weapon.equals("Tzhaar-ket-om") || weapon.equals("Torags hammers"))
        {
            p.frame.setSidebar(p, 425, 0);
            p.frame.setInterfaceItem(p, 426, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 428);
        }
        else if(weapon.equals("Veracs flail") || weapon.endsWith("mace"))
        {
            p.frame.setSidebar(p, 3796, 0);
            p.frame.setInterfaceItem(p, 3797, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 3799);
        }
        else if(weapon.endsWith("crossbow"))
        {
            p.frame.setSidebar(p, 1749, 0);
            p.frame.setInterfaceItem(p, 1750, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 1752);
        }
        else if(weapon.endsWith("bow") || weapon.endsWith("bow full") || weapon.equals("Seercull"))
        {
            p.frame.setSidebar(p, 1764, 0);
            p.frame.setInterfaceItem(p, 1765, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 1767);
        }
        else if(weapon.startsWith("Staff") || weapon.endsWith("staff") || weapon.equals("Toktz-mej-tal"))
        {
            p.frame.setSidebar(p, 328, 0);
            p.frame.setInterfaceItem(p, 329, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 331);
        }
        else if(weapon.endsWith("dart") || weapon.endsWith("knife") || weapon.endsWith("thrownaxe") || weapon.equals("Toktz-xil-ul"))
        {
            p.frame.setSidebar(p, 4446, 0);
            p.frame.setInterfaceItem(p, 4447, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 4449);
        }
        else if(weapon.endsWith("dagger") || weapon.endsWith("dagger(s)") || weapon.endsWith("dagger(+)") || weapon.endsWith("dagger(p)"))
        {
            p.frame.setSidebar(p, 2276, 0);
            p.frame.setInterfaceItem(p, 2277, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 2279);
        }
        else if(weapon.endsWith("pickaxe"))
        {
            p.frame.setSidebar(p, 5570, 0);
            p.frame.setInterfaceItem(p, 5571, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 5573);
        }
        else if(weapon.endsWith("axe") || weapon.endsWith("battleaxe"))
        {
            p.frame.setSidebar(p, 1698, 0);
            p.frame.setInterfaceItem(p, 1699, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 1701);
        }
        else if(weapon.endsWith("halberd"))
        {
            p.frame.setSidebar(p, 8460, 0);
            p.frame.setInterfaceItem(p, 8461, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 8463);
        }
        else if(weapon.endsWith("spear") || weapon.equals("Guthans warspear"))
        {
            p.frame.setSidebar(p, 4679, 0);
            p.frame.setInterfaceItem(p, 4680, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 4682);
        }
        else if(weapon.endsWith("claws"))
        {
            p.frame.setSidebar(p, 7762, 0);
            p.frame.setInterfaceItem(p, 7763, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 7764);
        }
        else if(weapon.endsWith("2h sword"))
        {
            p.frame.setSidebar(p, 4705, 0);
            p.frame.setInterfaceItem(p, 4706, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 4708);
        }
        else
        {
            p.frame.setSidebar(p, 2423, 0);
            p.frame.setInterfaceItem(p, 2424, 200, p.equipment[3]);
            p.frame.setText126(p, weapon, 2426);
        }
    }

    public int getRunEmote(int id)
    {
        String weapon = Main.m.ge.item.getItemName(id);
        if(id == 4718 || weapon.contains("2h") || id == 6528)
        {
            return 2563;
        }
        else if(weapon.equals("Saradomin staff") || weapon.equals("Guthix staff") || weapon.equals("Zamorak staff"))
        {
            return 0x338;
        }
        else if(id == 4755)
        {
            return 1831;
        }
        else if(id == 4734)
        {
            return 2077;
        }
        else if(id == 4726 || weapon.contains("Spear") || weapon.endsWith("halberd") || weapon.contains("Staff") || weapon.contains("staff"))
        {
            return 1210;
        }
        else if(weapon.equals("Abyssal whip"))
        {
            return 1661;
        }
        else if(id == 4153)
        {
            return 1664;
        }
        return 0x338;
    }

    public int getWalkEmote(int id)
    {
        String weapon = Main.m.ge.item.getItemName(id);
        if(weapon.equals("Saradomin staff") || weapon.equals("Guthix staff") || weapon.equals("Zamorak staff"))
        {
            return 0x333;
        }
        else if(id == 4755)
        {
           return 2060;
        }
        else if(id == 4734)
        {
           return 2076;
        }
        else if(id == 4153)
        {
            return 1663;
        }
        else if(weapon.equals("Abyssal whip"))
        {
           return 1660;
        }
        else if(id == 4718 || weapon.endsWith("2h sword") || id == 6528 || id == 1319)
        {
           return 2064;
        }
        else if(id == 4726 || weapon.contains("spear") || weapon.endsWith("halberd") || weapon.contains("Staff") || weapon.contains("staff"))
        {
           return 1146;
        }
        return 0x333;
    }

    public int getStandEmote(int id) 
    {
        String weapon = Main.m.ge.item.getItemName(id);
        if(id == 4718)
        {
            return 2065;
        }
        else if(id == 4755)
        {
            return 2061;
        }
        else if(id == 4734)
        {
            return 2074;
        }
        else if(id == 6528 || id == 1319)
        {
            return 0x811;
        }
        else if(weapon.equals("Saradomin staff") || weapon.equals("Guthix staff") || weapon.equals("Zamorak staff"))
        {
            return 0x328;
        }
        else if(id == 4726 || weapon.endsWith("spear") || weapon.endsWith("halberd") || weapon.contains("Staff") || 
        weapon.contains("staff") || id == 1305)
        {
            return 809;
        }
        else if(weapon.endsWith("2h sword"))
        {
            return 2561;
        }
        else if(weapon.equals("Abyssal whip"))
        {
            return 1832;
        }
        else if(id == 4153)
        {
            return 1662;
        }
        return 0x328;
    }
}